package com.gary.enums;


import java.util.HashMap;
import java.util.Map;

/**
 * 数据权限变量
 *
 * @author Homan Liang
 * @date 2019/11/1
 */
public enum DataPermissionVariableEnum {
    /**
     * 空字符串
     */
    EMPTY_STRING(1010, "#{emptyString}#", "空字符串"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getEmptyString"),
    /**
     * NULL
     */
    NULL_VALUE(1020, "#{nullValue}#", "null"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getNullValue"),
    /**
     * NOT NULL
     */
    NOT_NULL_VALUE(1021, "#{notNullValue}#", "not null"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getNotNullValue"),
    /**
     * 当前用户
     */
    CURRENT_USER(1030, "#{currentUser}#", "当前用户"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getCurrentUser"),
    /**
     * 当前用户权限部门
     */
    CURRENT_USER_DEPT(1040, "#{currentUserDept}#", "当前用户权限部门"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getUserDept"),
    /**
     * 当前用户权限部门（包含子部门）
     */
    CURRENT_USER_DEPT_WITH_CHILD(1041, "#{currentUserDeptWithChild}#", "当前用户权限部门（包含子部门）"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getUserDeptWithChild"),
    /**
     * 当前时间
     */
    NOW(1050, "#{now}#", "当前时间"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getNow"),
    /**
     * 当天
     */
    TODAY(1051, "#{today}#", "当天"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getToday"),
    /**
     * 当前用户所属部门的用户（不包含子部门）
     */
    CURRENT_USER_DEPARTMENT_USER(1060, "#{currentUserDepartmentUser}#", "当前用户所属部门的用户（不包含子部门）"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getUserDepartmentUserIdList"),
    /**
     * 当前用户所属部门的用户（包含子部门）
     */
    CURRENT_USER_DEPARTMENT_WITH_CHILD_USER(1070, "#{currentUserDepartmentWithChildUser}#", "当前用户所属部门的用户（包含子部门）"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getUserDepartmentWithChildUserIdList"),
    /**
     * 当前用户所属权限部门的用户（不包含子部门）
     */
    CURRENT_USER_DEPT_USER(1080, "#{currentUserDeptUser}#", "当前用户所属权限部门的用户（不包含子部门）"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getUserDeptUserIdList"),
    /**
     * 当前用户所属权限部门的用户（包含子部门）
     */
    CURRENT_USER_DEPT_WITH_CHILD_USER(1090, "#{currentUserDeptWithChildUser}#", "当前用户所属权限部门的用户（包含子部门）"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getUserDeptWithChildUserIdList"),
    /**
     * 采购内部对应关系
     */
    PURCHASER_DP_USER_RELATION(1100, "#{purchaserDpUserRelation}#", "采购内部对应关系"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getPurchaserDpUserRelation"),
    /**
     * 销售内部对应关系
     */
    CRM_USER_RELATION_SHIP(1110, "#{crmUserRelationShip}#", "销售内部对应关系"
            , "com.allchips.backend.core.service.model.dataPermission.impl.DataPermissionVariableGetService.getCrmUserRelationShip"),
    ;

    /**
     * 编号
     */
    private int code;
    /**
     * 名称
     */
    private String name;
    /**
     * 名称(中文)
     */
    private String nameCn;
    /**
     * 方法路径
     */
    private String methodPath;

    private static final Map<Integer, DataPermissionVariableEnum> LOOK_UP_CODE = new HashMap<>();

    private static final Map<String, DataPermissionVariableEnum> LOOK_UP_NAME = new HashMap<>();

    static {
        for (DataPermissionVariableEnum ase : DataPermissionVariableEnum.values()) {
            LOOK_UP_CODE.put(ase.getCode(), ase);
            LOOK_UP_NAME.put(ase.getName(), ase);
        }
    }

    DataPermissionVariableEnum(int code, String name, String nameCn, String methodPath) {
        this.code = code;
        this.name = name;
        this.nameCn = nameCn;
        this.methodPath = methodPath;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNameCn() {
        return nameCn;
    }

    public void setNameCn(String nameCn) {
        this.nameCn = nameCn;
    }

    public String getMethodPath() {
        return methodPath;
    }

    public void setMethodPath(String methodPath) {
        this.methodPath = methodPath;
    }

    public static DataPermissionVariableEnum get(Integer code) {
        return LOOK_UP_CODE.get(code);
    }

    public static DataPermissionVariableEnum get(String name) {
        return LOOK_UP_NAME.get(name);
    }
}
